<template>
	<view class="cate">
		<view class="cate-con">
			<!-- 左边 -->
			<scroll-view scroll-y="true" class="left">
				 <view class="name" :class="{active:currentIndex == index}" v-for="item,index in cateList" :key="index" @click="change(index)">
				 	 {{item.categoryName}}
				 </view>
			</scroll-view>
			<!-- 右边 -->
			<scroll-view scroll-y="true" class="right">
				<view class="" v-for="item,index in twoList" :key="index">
					<view class="name">
						{{item.categoryName}}
					</view>
					<view class="child">
						<view class="child-item" v-for="ele,i in item.thirdLevelCategoryVOS" :key="i">
							<image src="../../static/logo.png" mode="" class="img"></image>
							<view class="title">
								{{ele.categoryName}}
							</view>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cateList:[],
				currentIndex:0,
				twoList:[]
			};
		},
		onLoad() {
			uni.request({
				url:'http://backend-api-01.newbee.ltd/api/v1/categories',
				method:"GET",
				success: (res) => {
					console.log(res.data.data)
					this.cateList = res.data.data
					this.change(0)
				}
			})
		},
		methods:{
			change(index){
				this.currentIndex = index
				this.twoList = this.cateList[index].secondLevelCategoryVOS
			}
		}
	}
</script>

<style lang="scss">
.cate{
	height: 100vh;
	.cate-con{
		width: 100%;
		height: 100%;
		display: flex;
		padding: 0 20rpx;
		box-sizing: border-box;
		.left{
			height: 100%;
			width: 200rpx;
			font-size: 28rpx;
			.name{
				height: 80rpx;
				line-height: 80rpx;
			}
			.active{
				color: aquamarine;
			}
			
		}
		.right{
			flex:1;
			.name{
				width: 100%;
				text-align: center;
			}
			.child{
				display: flex;
				flex-wrap: wrap;
				.child-item{
					font-size: 24rpx;
					text-align: center;
					
					margin:20rpx;
					box-sizing: border-box;
					.img{
						width: 80rpx;
						height: 80rpx;
						
					}
				}
			}
			
		}
	}
	
}
</style>
